#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/7/17 17:27
# @Author  : Chenmm
# @File    : api.py
# @Software: PyCharm
# @Des: api路由


from fastapi import APIRouter, Security
from api.endpoints.test import test_oath2
from api.endpoints import user, role, access, websocket
from api.extends import sms, wechat, cos
from core.Auth import check_permissions


api_router = APIRouter(prefix="/api/v1")
api_router.post("/test/oath2", tags=["测试oauth2授权接口"])(test_oath2)
api_router.include_router(user.router, prefix='/admin', tags=["用户管理"])
api_router.include_router(role.router, prefix='/admin', tags=["角色管理"])
api_router.include_router(access.router, prefix='/admin', tags=["权限管理"])
api_router.include_router(websocket.router, prefix='/ws', tags=["WebSocket"])
api_router.include_router(wechat.router, prefix='/wechat', tags=["微信授权"])
api_router.include_router(sms.router, prefix='/sms', tags=["短信接口"])
api_router.include_router(cos.router, prefix='/cos', tags=["对象存储接口"])


@api_router.get("/admin/get-menu-list", tags=["菜单管理"], summary="获取菜单",dependencies=[Security(check_permissions)])
async def get_menu_list():
    result = {
        "code": 0,
        "data": {
            "list": [
                {
                    "path": "/list",
                    "name": "list",
                    "component": "LAYOUT",
                    "redirect": "/list/base",
                    "meta": {
                        "title": "列表页",
                        "icon": "view-list"
                    },
                    "children": [
                        {
                            "path": "base",
                            "name": "ListBase",
                            "component": "/list/base/index",
                            "meta": {
                                "title": "基础列表页"
                            }
                        },
                        {
                            "path": "card",
                            "name": "ListCard",
                            "component": "/list/card/index",
                            "meta": {
                                "title": "卡片列表页"
                            }
                        },
                        {
                            "path": "filter",
                            "name": "ListFilter",
                            "component": "/list/filter/index",
                            "meta": {
                                "title": "筛选列表页"
                            }
                        },
                        {
                            "path": "tree",
                            "name": "ListTree",
                            "component": "/list/tree/index",
                            "meta": {
                                "title": "树状筛选列表页"
                            }
                        }
                    ]
                },
                {
                    "path": "/form",
                    "name": "form",
                    "component": "LAYOUT",
                    "redirect": "/form/base",
                    "meta": {
                        "title": "表单页",
                        "icon": "edit-1"
                    },
                    "children": [
                        {
                            "path": "base",
                            "name": "FormBase",
                            "component": "/form/base/index",
                            "meta": {
                                "title": "基础表单页"
                            }
                        },
                        {
                            "path": "step",
                            "name": "FormStep",
                            "component": "/form/step/index",
                            "meta": {
                                "title": "分步表单页"
                            }
                        }
                    ]
                },
                {
                    "path": "/detail",
                    "name": "detail",
                    "component": "LAYOUT",
                    "redirect": "/detail/base",
                    "meta": {
                        "title": "详情页",
                        "icon": "layers"
                    },
                    "children": [
                        {
                            "path": "base",
                            "name": "DetailBase",
                            "component": "/detail/base/index",
                            "meta": {
                                "title": "基础详情页"
                            }
                        },
                        {
                            "path": "advanced",
                            "name": "DetailAdvanced",
                            "component": "/detail/advanced/index",
                            "meta": {
                                "title": "多卡片详情页"
                            }
                        },
                        {
                            "path": "deploy",
                            "name": "DetailDeploy",
                            "component": "/detail/deploy/index",
                            "meta": {
                                "title": "数据详情页"
                            }
                        },
                        {
                            "path": "secondary",
                            "name": "DetailSecondary",
                            "component": "/detail/secondary/index",
                            "meta": {
                                "title": "二级详情页"
                            }
                        }
                    ]
                },
                {
                    "path": "/frame",
                    "name": "Frame",
                    "component": "Layout",
                    "redirect": "/frame/doc",
                    "meta": {
                        "icon": "internet",
                        "title": "外部页面"
                    },
                    "children": [
                        {
                            "path": "doc",
                            "name": "Doc",
                            "component": "IFrame",
                            "meta": {
                                "frameSrc": "https://tdesign.tencent.com/starter/docs/vue-next/get-started",
                                "title": "使用文档（内嵌）"
                            }
                        },
                        {
                            "path": "TDesign",
                            "name": "TDesign",
                            "component": "IFrame",
                            "meta": {
                                "frameSrc": "https://tdesign.tencent.com/vue-next/getting-started",
                                "title": "TDesign 文档（内嵌）"
                            }
                        },
                        {
                            "path": "TDesign2",
                            "name": "TDesign2",
                            "component": "IFrame",
                            "meta": {
                                "frameSrc": "https://tdesign.tencent.com/vue-next/getting-started",
                                "frameBlank": True,
                                "title": "TDesign 文档（外链）"
                            }
                        }
                    ]
                }
            ]
        }
    }
    return result

